Release 10.1A: OpenEdge Getting Started:
Progress OpenEdge Studio


Detailed Order section procedure

The following sections describe building the Order section in detail.

Adding a SDO for orders

As in the Customer section, the SDOs are the first objects to add to the Order section. The Order section needs SDOs that query the database for orders and the order lines that make up that order.

To add an Order SDO:

  1. Choose the SDO icon in the Object Palette to open the Choose SmartDataObject dialog box.
  2. Select dorder.w and choose OK.
  3. Click once in the Order section. You do not need to position a SDO precisely, since it is invisible when an application is running. The Progress Advisor notifies you that the SDO instance, h_dorder, can be a Data Target for some other SmartObject, and offers to add a Data SmartLink from the SDO instance, h_dcust.
  4. Select the radio button to create the SmartLink and choose OK. The Progress Advisor notifies you that h_dorder and h_dcust are both Query Objects, and asks whether you want to specify foreign fields:
  5. Select the radio button to choose foreign fields and choose OK. The Multi-Field Mapping dialog box appears.
  6. Select CustNum in the Source and Order.CustNum in the Target list:
  7. Choose Map. The field pair is displayed in the Mapped Fields field.
  8. Choose OK. The new SDO, dorder.w, appears in the main window.
Adding a SDO for order lines

You are now going to add another SDO, dordlne, to the Order section.

To add an Order Lines SDO:

  1. Choose the SDO icon in the Object Palette to open the Choose SmartDataObject dialog box.
  2. Select dordlne.w and choose OK.
  3. Place the new SDO under the other SDO. This is only for convenience, their positions do not affect how they operate. The Progress Advisor notifies you that the SDO instance, h_dordlne, can be a Data Target for some other SmartObject, and offers to add a Data SmartLink from either of the other SDO instances:
  4. Choose the radio button to create the SmartLink to h_dorder and choose OK. The Progress Advisor notifies you that h_dordlne and h_dorder are both Query Objects and asks if you want to choose foreign fields.
  5. Choose the radio button to select foreign fields and then choose OK. The Multi-Field Mapping dialog box appears.
  6. Select Ordernum in the Source list and OrderLine.Ordernum in the Target list.
  7. Choose Map. The field pair is displayed in the Mapped Fields field.
  8. Choose OK. The new SDO, dordlne, appears in the design window:
  9. Save your work.
Adding a SDV

The next object to add is a SDV that displays the order information.

To add a SDV for displaying order information:

  1. Choose the SDV icon in the Object Palette to open the Choose SmartDataViewer dialog box.
  2. Select vorder.w and choose OK.
  3. Click within the Order section to add the SDV. The Progress Advisor notifies you that SDV instance, h_vorder, should be a Data Target for some other SmartObject, and offers to create a Data SmartLink from the SDO instance, h_dorder.
  4. Select the radio button to create the SmartLink and choose OK. The Progress Advisor notifies you that the SDV instance, h_vorder, should be an Update source for some other SmartObject, and offers to add an Update SmartLink to the SDO instance, h_dorder.
  5. Select the radio button to create the SmartLink and choose OK. The SDV appears in the main window.
  6. Position the SDV near the top of the Order section and aligned on the right edge. Your window should look something like the following figure:
Adding buttons to the Order section

You need to add buttons to the Order section, as you did to the Customer section. Follow the procedures in "Creating and positioning the buttons" section and "Adding ToolTips, help IDs, and images to the buttons" section to add and customize the three buttons to the Order section.

To customize the buttons, use the values in the following table:

Object
Left
Height
Width
ToolTip
Help ID
Image
BUTTON-3
14
2.38
10
Place New Order
3
crtord.jpg 
BUTTON-4
14
2.38
10
Find Order
4
findord.jpg 
BUTTON-5
14
2.38
10
Maintain Order
5
mainord.jpg 

Note: You do not need to add a Help file for the Order section buttons. The Help file you added while building the Customer section controls the Help for the entire window. It applies to all sections of the window.

When you finish, your window should look like the following window:

Coding event triggers for the Order buttons

You need to add CHOOSE event triggers to the buttons, as you did in the Customer section. Follow the procedures in "Coding event triggers for the buttons" section.

Using the Section Editor, add the following code to the CHOOSE events of the buttons in this section:

Button
Code
BUTTON-3
RUN wmntord.w (h_dcust, h_dorder, h_dordlne). 
BUTTON-4
RUN wfndord2.w(h_dorder). 
BUTTON-5
RUN wmntord.w (h_dcust, h_dorder, h_dordlne). 

The remaining objects to add to the Order section are two Object Component Extension (OCX) controls, also known as ActiveX controls.

Adding OCX controls

In this section, you add Object Component Extension (OCX) controls to your window. An OCX (also called an ActiveX control) is a predefined object widget that you include in a control-frame to add prepackaged functionality to your applications.

ActiveX objects are Common Object Model (COM) objects that provide a form of interprocess communication with other Windows applications along the Microsoft ActiveX specifications. For more information about ActiveX Automation, see the OpenEdge Development: Programming Interfaces manual.

The OpenEdge Studio ships with three licensed OCX controls:

With the AppBuilder, you can integrate third-party objects, like OCXs, into your applications in the same way you build SmartObjects. For example, in this section, you choose the OCX spin box from the Object Palette, position and resize it visually in the window, and write user-interface triggers for it using the Section Editor. For more detailed information about ActiveX (OCX controls) and the AppBuilder, see the OpenEdge Development: AppBuilder .

Selecting an OCX object

In this section, you add two OCX spin box controls to the Order section. These OCX controls are used to navigate through the records in the SDO, dorder, which sends the order information to the SDV, vorder, for viewing.

To add OCX controls to the Order section:

  1. Double-click the OCX icon in the Object Palette. The Choose Control dialog box appears:
  2. Note: If you installed other OCX controls, they should also appear in the Available Controls list.

  3. Select the Crescent Spin Control in the Available Controls list. When you select an OCX control, the location and control name appear at the bottom of the Choose Control dialog box.
  4. Choose OK to return to your design window.
  5. Add two spin boxes to the Order section. The spin boxes appear with their default dimensions. Your window should appear similar to the following window:
Changing the appearance of the OCX controls

The OCX spin boxes are too large and oriented in the wrong direction. You need to resize the OCX spin boxes, change their orientation, and add text labels and borders.

To resize the OCX spin boxes and change their orientation:

  1. Use the Window Properties Window option in the AppBuilder menu to set the control frames’ Heights to 1.52 and their Widths to 9.0.
  2. See the "Creating and positioning the buttons" section for information on using the Properties Window.

  3. Double-click the left spin box to open the Property Editor dialog box:
  4. Select the Style property and set it to Style 3 - 3D Horizontal.
  5. Select the ArrowColor property and set it to dark blue.
  6. Close the property sheet.
  7. Repeat Step 2 through Step 5 for the right spin box. Your window should now look something like this:
  8. Use the Text icon in the Object Palette to add the colored text labels, Prev/Next, below the left spin box and First/Last below the right spin box. See the "Adding text labels to the sections" section to review this procedure.
  9. Use the Rectangle icon in the Object Palette to add a rectangle around each spin box:
Coding the Prev/Next spin box to fetch the previous record

You need to code the OCX controls in your window to navigate through the Order records. First, you will code the Prev/Next spin box to fetch the previous record.

To add trigger code to fetch the previous record:

  1. Select the Prev/Next spin box and open the Section Editor.
  2. Choose the New button to open the Choose Event dialog box:
  3. Select OCX.SpinDown from the Common OCX Events list. The Section Editor now displays the new code section:
  4. Position the cursor between the Header comments and the END PROCEDURE statement.
  5. Choose the Insert Call button to open the Insert Procedure Call dialog box:
  6. Select h_dorder from the Procedure Object drop-down list.
  7. Select the Procedures radio button in the Entries in Object section, and select fetchPrev. The Code to Insert field shows a preview of the code for this procedure call:
  8. Choose OK. The new code appears in the Section Editor:
Coding the Prev/Next spin box to fetch the next record

Now, you need to code the Prev/Next spin box to fetch the next record.

To add trigger code to fetch the next record:

  1. Choose New in the Section Editor to open the Choose Event dialog box.
  2. Select OCX.SpinUp in the Common OCX Events list.
  3. Position the cursor between the Header comments and the END PROCEDURE statement.
  4. Choose the Insert Call button to open the Insert Procedure Call dialog box.
  5. Select h_dorder from the Procedure Object drop-down list.
  6. Select the Procedures radio button in the Entries in Object section.
  7. Select fetchNext and choose OK. The new trigger code appears in the Section Editor.
  8. Choose File Close Window to save the new code and close the Section Editor.
Coding the First/Last spin box to fetch the first and last records

The second spin box fetches the first or last record in the Order SDO. The only thing that differs from what you did for the Prev/Next spin box is the procedure called by the spin events. First, you add the code to fetch the first record.

To add trigger code to fetch the first record, repeat the procedure in "Coding the Prev/Next spin box to fetch the previous record" section. Use the fetchFirst procedure, instead of the fetchPrev procedure.

Now, you add the code to fetch the last record.

To add trigger code to fetch the last record, repeat the procedure in "Coding the Prev/Next spin box to fetch the next record" section. Use the fetchLast procedure, instead of the fetchNext procedure.

You can now save your window and have a look at how it runs so far.

Viewing the window

You have now completed assembling the Customer and Order sections of the application’s main window. If you want to view and test the partially assembled application, run the application to view the window at this point in the assembly. Before you run the application, save your work.

To view the partially assembled window:

  1. Choose the Run icon on the AppBuilder toolbar. Your window should appear as it would in a running application. The main window of the sample application should look like the following window:
  2. Hold your pointer over a button to view the ToolTip.
  3. Choose the context sensitive help button (?) in the upper-right corner of the window and then choose a button to see the context sensitive help.
  4. Choose one of the buttons to launch another module.
  5. Choose the Stop icon on the AppBuilder toolbar to return to the main window.

Now you can move on to building the Order Line section.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095